/**
 * @Author: Liu, Yunfeng
 * @DateTime: 2021/3/4 20:18
 * @Description: 给定一个排序链表，删除所有重复的元素，使得每个元素只出现一次。
 */
public class deleteDuplicates {
    public static ListNode deleteDuplicates(ListNode head) {
        int tmp;
        ListNode currentNode = head;
        while (currentNode != null && currentNode.next != null) {
            tmp = currentNode.val;
            if (currentNode.next.val == tmp) {
                currentNode.next = currentNode.next.next;
                continue;
            }
            currentNode = currentNode.next;
        }
        return head;
    }

    public static void main(String[] args) {
        int[] nums = {1, 7};
        ListNode head = ListNode.makeListNode(nums);
        ListNode.printListNode(deleteDuplicates(head));
    }
}
